<?php
/**
 * Core class of iLivGallery, give you everything you need to
 * open directories and parse for images.
 *
 * PHP 5
 *
 * MIT License
 * Copyright (c) 2009 Christian Krause
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @category   library
 * @package    iLivGallery
 * @author     Original Author <ilivgallery@christiankrause.de>
 * @copyright  2009 Christian Krause
 * @license    MIT
 * @link       http://code.google.com/p/ilivgallery/downloads/
 * @since      File available since Release 0.5
 */

class DebuggerFactory {

	static public function create($type) {

		$type = strtolower($type);
		switch($type) {
			case 'echo':
				$instance = DebuggerEcho::getInstance();
			break;

//			case 'log':
//				$instance = DebuggerEcho::getInstance();
//			break;
		}

		return $instance;
	}

}

interface iLiv_Debugger {

	public function setError($class, $function, $error);
	public function debug();

}

class DebuggerEcho implements iLiv_Debugger {

	protected $errArray;
	static private $instance = null;

	static public function getInstance() {

		if ( self::$instance == null )
		{
			self::$instance = new self;
		}

		return self::$instance;
	}

/*
 * Set errors of your class with this function
 */

	public function setError($class, $function, $error) {
		$this->errArray[$class][$function][] = $error;
	}

	public function dump($class, $function, $error) {
		var_dump($class, $function, $error);//$this->errArray[$class][$function][] = $error;
	}

    public function debug() {

    	if ( !empty($this->errArray) ) {
			echo '<pre>';
			var_dump($this->errArray);
			echo '</pre>';
    	}

    }
}

/*
 * TODO: Implementieren eines Log Debuggers
 */
